﻿-var date = (DateTime)ViewData["Date"] 
-int days = DateTime.DaysInMonth(date.Year,date.Month)
-var firstday = (DateTime)ViewData["Firstday"]
-int rows = (int)ViewData["Rows"]
-var tasks = ViewData["Tasks"] as List<Task>
%table.scheduleheader
  %tr
    %th{width="14%"} Пн.
    %th{width="14%"} Вт.
    %th{width="14%"} Ср.
    %th{width="14%"} Чт.
    %th{width="14%"} Пт.
    %th{width="14%"} Сб.
    %th{width="14%"} Вс.
%table.schedule
  -for(int i=0;i<rows;i++)
    %tr
      -for(int d=0;d<7;d++)
        -var cdate = firstday.AddDays(i*7+d)
        -int taskCount = tasks.Where(t=>t.StartDate.Date==cdate).Count()
        -string cls = taskCount > 0 ? " workingday":""
        %td{width="14%",class=(cdate.Month==date.Month?"active":"inactive")+cls,onclick=string.Format("$('#date').val('{0}'); dateChanged();",cdate.ToDateString())}
          %span.sday=cdate.ToString("dd")
          %span.smonth=cdate.ToString("MMM")
          -if(taskCount>0 && cdate.Month==date.Month)
            .big
              %a.dashed{href="#",onclick=string.Format("return showDayDetails(this,'{0}')",cdate.ToDateString())}=taskCount.Decline("заяв-ка,ки,ок",true)
          -else if(taskCount>0)
            .big
              =taskCount.Decline("заяв-ка,ки,ок",true)